/*
 * @Author: 邱狮杰
 * @Date: 2021-09-05 11:27:35
 * @LastEditTime : 2021-09-08 18:41:42
 * @FilePath     : /smallnewhope/src/hooks/userInit.ts
 * @Description: 描述
 */
import { useStore } from "vuex";
import { useHttp } from "./http";
import { State } from "/@/store/user";

export function useUserInit() {
  const store = useStore();
  const [http] = useHttp();
  async function send() {
    await http<{
      data: {
        awards: State["prizeList"];
        fans: State["userInfo"];
        myawards: State["myawards"];
      };
    }>(
      {
        method: "GET",
        params: {
          i: 3,
          logout: 1,
          action: "index",
        },
      },
      (response) => {
        store.commit("user/initUserInfo", response.data.data.fans);
        store.commit("user/initPrizeList", response.data.data.awards);
        store.commit("user/initMyAwards", response.data.data.myawards);
      },
      () => { }
    );
  }

  return [send];
}
